<template>
    <a-card v-if="isShow==1" style="margin-bottom: 15px" size="small">
        <template #title>
            <span style="color:#1677ff ;">项目预算列表</span>
            <a-tooltip title="返回上级">
                <a-button style="float: right;" size="middle" @click="goback">
                    <template #icon>
                        <RollbackOutlined />
                    </template>
                </a-button>
            </a-tooltip>
        </template>
        <!---------- 表格 begin ----------->
        <a-table size="small" :dataSource="tableData" :columns="columns" rowKey="blfunduseid" bordered
            :loading="tableLoading" :pagination="false" :scroll="{ x: 1500}">
            <template #bodyCell="{ text, record, column }">
                <template v-if="column.dataIndex === 'blext3'">
                    <div class="smart-table-operate">
                        <a type="link" style="color: #1878ff;" @click="budgetDetail(record)">
                            {{record.blext3}}</a>
                    </div>
                </template>
                <template v-if="column.dataIndex === 'blaudit'">
                    <div class="smart-table-operate">
                        <div type="link">{{record.blaudit==7?'申报成功':'申报未完成'}}</div>
                    </div>
                </template>
            </template>
        </a-table>
    </a-card>
    <BudgetDetail v-else-if="isShow==2" @emitPass="changeShow" :passData="passData" />
</template>

<script setup>
    import BudgetDetail from '../../../../ProManage/modules/BudgetDetail.vue';
    import { nextTick, reactive, ref, defineProps, onMounted, unref, toRefs, toRaw } from 'vue';
    import { message, Modal } from 'ant-design-vue';
    const props = defineProps({
        passParams: {
            type: Object,
        },
    })
    const emits = defineEmits(['emitPass'])
    function goback() {
        emits('emitPass', true)
    }
    // 控制父组件是否展示
    const isShow = ref(true);
    // 改变父组件展示状态
    function changeShow() {
        isShow.value = 1;
    }
    const passData = ref({});
    function budgetDetail(data) {
        isShow.value = 2;
        passData.value = data;
    }
    // ---------------------------- 表格列 ----------------------------
    const columns = ref([
        {
            title: '项目名称',
            dataIndex: 'blext3',
            align: 'center',
            fixed: 'left',
            width: 140,
        },
        {
            title: '项目申报单位',
            dataIndex: 'blaccount',
            align: 'center',
        },
        {
            title: '项目预算年度',
            dataIndex: 'blyear',
            align: 'center',
        },
        {
            title: '项目申报时间',
            dataIndex: 'bldate',
            align: 'center',
            sorter: {
                compare: (a, b) => new Date(a.bldate) - new Date(b.bldate),
            },
        },
        {
            title: '项目申报金额',
            dataIndex: 'sum',
            align: 'center',
            sorter: {
                compare: (a, b) => a.sum - b.sum,
            },
        },
        {
            title: '项目编号',
            dataIndex: 'blprojectnum',
            align: 'center',
        },
        {
            title: '是否申报成功',
            dataIndex: 'blaudit',
            align: 'center',
        },
    ]);
    // 表格加载loading
    const tableLoading = ref(false);
    // 表格数据
    const tableData = ref([]);
    // 总数
    const total = ref(0);
    const dataTable = props.passParams
    // 表格赋值
    tableData.value = dataTable
    // 选择表格行
    const selectedRowKeyList = ref([]);

    function onSelectChange(selectedRowKeys) {
        selectedRowKeyList.value = selectedRowKeys;
    }

</script>

<style lang="less" scoped>
    ::v-deep.ant-card .ant-card-head-title {
        margin: 10px 0px;
        font-size: 16px;
    }
</style>